package net.larsan.dconf.util;

import static org.apache.commons.lang.Validate.notNull;
import net.larsan.dconf.DNode;

/**
 * Static utility class.
 * 
 * @author Lars J. Nilsson
 */
public class DNodes {

	private DNodes() { }
	
	/**
	 * @param node Node to find root (top-most ascendant) for, must not be null
	 * @return The root of the node, never null
	 */
	public static DNode findRoot(DNode node) {
		notNull(node);
		while(node.getParent() != null) {
			node = node.getParent();
		}
		return node;
	}
}
